package com.party.notify.notifyPush.activity;

import com.party.core.exception.BusinessException;
import com.party.core.model.notify.TargetTemplateType;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by wei.li
 *
 * @date 2017/8/9 0009
 * @time 11:00
 */

@Service
public class ActivitySendFactory {

    @Resource(name = "auditingPassSendService")
    private INotifyActivitySendService auditingPassSendService;

    @Resource(name = "auditingSendService")
    private INotifyActivitySendService auditingSendService;

    @Resource(name = "auditRejectSendService")
    private INotifyActivitySendService auditRejectSendService;

    @Resource(name = "cancelSendService")
    private INotifyActivitySendService cancelSendService;

    @Resource(name = "paidSendService")
    private INotifyActivitySendService paidSendService;

    @Resource(name = "allSendService")
    private INotifyActivitySendService allSendService;

    /**
     * 获取发送器
     * @param targetTemplateType 模板类型
     * @return 发送器
     */
    public INotifyActivitySendService getSender(TargetTemplateType targetTemplateType){
        if (targetTemplateType.getType().equals(0)){
            throw new BusinessException("不能发送众筹推送");
        }

        if (TargetTemplateType.ACT_STATUS_AUDITING.getCode().equals(targetTemplateType.getCode())){
            return auditingSendService;
        }
        if (TargetTemplateType.ACT_STATUS_AUDIT_PASS.getCode().equals(targetTemplateType.getCode())){
            return auditingPassSendService;
        }
        if (TargetTemplateType.ACT_STATUS_AUDIT_REJECT.getCode().equals(targetTemplateType.getCode())){
            return auditRejectSendService;
        }
        if (TargetTemplateType.ACT_STATUS_PAID.getCode().equals(targetTemplateType.getCode())){
            return paidSendService;
        }
        if (TargetTemplateType.ACT_STATUS_CANCEL.getCode().equals(targetTemplateType.getCode())){
            return cancelSendService;
        }
        if (TargetTemplateType.ACT_STATUS_ALL.getCode().equals(targetTemplateType.getCode())){
            return allSendService;
        }
        return null;
    }
}
